package com.weight.common.generate.temple;

import java.util.List;
import java.util.Map;

import com.weight.common.generate.base.ResourceFile;


/**
* 
*  
*/
public class AddHtmlResourceFile extends ResourceFile {
	private static final String FILE_NAME = ".html";
	
	public AddHtmlResourceFile(String filePath,String packageName,String model,List<String> fieldENList,List<String> fieldCNList,String tableCnName) {
		
		super(filePath,new StringBuilder("add").append(getModelClass(model)).append(FILE_NAME).toString());
		
		
		StringBuilder  resourceFile =new StringBuilder();
		
		resourceFile.append("<div th:id=\"'SS'+${formID}\" class=\"easyui-layout\"  style=\"padding:10px 20px 20px 20px;width:100%;\">\n");
		resourceFile.append("\t<form th:id=\"${formID}\" th:action=\"@{/").append(packageName).append("/").append(model).append("/")
					.append("save").append(getModelClass(model)).append("}\"  method=\"post\" enctype=\"multipart/form-data\">  \n");
		
		resourceFile.append("\t\t\t<input type=\"hidden\" name=\"").append(fieldENList.get(0)).append("\" th:value=\"${")
					.append(model).append("VO?.").append(fieldENList.get(0)).append("}\" /> \n");
		resourceFile.append("\t\t<div>\n"); 
		resourceFile.append("\n");
		
		for(int i=1;i<fieldENList.size();i++) {
			resourceFile.append("\t\t\t<div style=\"float:left;margin-bottom:20px;margin-left:20px;\">\n");
		 
			resourceFile.append("\t\t\t\t<input class=\"easyui-textbox wd50\" type=\"text\" data-options=\"required:true\"")
			
						.append("\n\t\t\t\t\tth:label=\"#{").append(model).append(".").append(fieldENList.get(i))
						.append("}+'  :'\" label=\"").append(fieldCNList.get(i)).append("\"")
						
						.append("\n\t\t\t\t\tth:prompt=\"'请填写'+#{").append(model).append(".").append(fieldENList.get(i))
						.append("}\" prompt=\"请填写").append(fieldCNList.get(i)).append("\"")
						
						.append("\n\t\t\t\t\tname=\"").append(fieldENList.get(i)).append("\" th:value=\"${")
						.append(model).append("VO?.").append(fieldENList.get(i)).append("}\" /> \n");
			
			resourceFile.append("\t\t\t</div>\n");
			resourceFile.append("\t\t\t<br style=\"clear:both;\">\n");
		}
		resourceFile.append("\t\t</div>\n");
		resourceFile.append("\t</form> \n");
		resourceFile.append("\t \n");
		
		resourceFile.append("\t<br style=\"clear:both;\"> \n");
		resourceFile.append("\t<div style=\"text-align:right;padding:5px\"> \n");
		resourceFile.append("\t\t<a href=\"javascript:void(0)\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-save'\" th:onclick=\"'javascript:submitForm(\\''+${formID}+'\\')'\">提交</a> \n");
		resourceFile.append("\t\t<a th:if=\"${").append(model).append("VO?.").append(fieldENList.get(0))
					.append("==null}\"  href=\"javascript:void(0)\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-remove'\" th:onclick=\"'javascript:clearForm(\\''+${formID}+'\\')'\">清空</a> \n");
		resourceFile.append("\t\t<a href=\"javascript:void(0)\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-remove'\" th:onclick=\"'javascript:cancelForm(\\''+${formID}+'\\')'\">取消</a> \n");
		resourceFile.append("\t</div> \n");
		
		
		resourceFile.append("</div>\n");
		resourceFile.append("<script type=\"text/javascript\">\n");
		resourceFile.append("</script>\n");
		
		
		resourceFile.append("\n");
		
		String resource = resourceFile.toString();
		init(resource);
	}
}
